<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>倒计时</title>

    <script>

        function countDown(time) {

            var currentTime = Date.now();
            var inputTime = new Date(time);
            // 把输入时间转化成毫秒值
            // var inputTime = input.valueOf();
            var count = (inputTime - currentTime) / 1000;

            var d = parseInt(count / 60 / 60 / 24);
            d = d < 10 ? '0' + d : d;

            var h = parseInt(count / 60 / 60 % 24);
            h = h < 10 ? '0' + h : h;

            var m = parseInt(count / 60 % 60);
            m = m < 10 ? '0' + m : m;

            var s = parseInt(count % 60);
            s = s < 10 ? '0' + s : s;

            return '还剩' + d + '天' + h + '时' + m + '分' + s + '秒';

        }

        var result = countDown('2020-10-1 20:00:00');
        console.log(result);


    </script>



</head>

<body>

</body>

</html>